package com.laosg.study.base.ch2

/**
  * Created by kaimin on 4/5/2019.
  * time : 20:51
  */
object LazyDemo {
  def main(args: Array[String]): Unit = {


    //只能修饰val 类型的变量
    lazy val res = sum(1, 2)
    println("-------")
    println("res=" + res)
    try {
      var res=10/0
    }catch {
      case ex:ArithmeticException=>{
        println("分母不能为0")
      }
      case ex:Exception=>{
        println("最大的异常")
      }
    }finally {
      println("到达组后的执行")
    }

//    var r=thr()
//    println(r)

    div()
  }
  def sum(a: Int, b: Int): Int = {
    println("------zhix-")
    a + b
  }

  def thr(): Nothing ={
    throw new Exception("budui")
  }
  @throws(classOf[ArithmeticException])
  def div(): Unit ={
    10/0
  }
}
